

/*
export function initQueryForm(queryFormCode) {
  console.log("initQueryForm",queryFormCode);
  const promise = new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        
      });
//        reject(`失败！数字是：${randomNumber}`);
    }, 1000);
  });
  return promise;
}
*/

const initQueryFormResult = {
  queryFormDef: {
    conds: [{
      condType: 'lt',
      component: {
        type: "sfInput",
        name: "输入框1",
        code: "mytext1"
      }
    },
    // {
    //   condType: 'lt',
    //   component: {
    //     type: "sfSelect",
    //     name: "输入框2",
    //     code: "myselect2",
    //     options: [{
    //       label: '选择1',
    //       value: 1
    //     },{
    //       label: '选择2',
    //       value: 2
    //     }]
    //   }
    // },
    {
      condType: 'between ',
      component: {
        type: "sfDateRange",
        name: "日期区间3",
        codeStart: "dateStart",
        codeEnd: "dateEnd"
      }
    }
    ],
    tools: {
      add: {
        perm:'sf:abc:add',
        opened: true
      },
      delete: {
        perm:'sf:delete:add',
        opened: true
      },
      upload: {
        perm:'sf:abc:upload',
        opened: true
      },
      export: {
        perm:'sf:abc:add',
        opened: true
      }
    },
    toolExts: [{
      name: "自查",
      elType: "primary",
      elIcon: "el-icon-download",
      actionType: 'query', // query查询 / ids数据处理
      url: '/api/simpleFormDefinition/list',
      opened: true
    }],
    operations: {
      modify: {
        perm: 'sf:abc:add',
        opened: true
      },delete: {
        perm: 'sf:abc:delete',
        opened: true
      }
    },
    operationExts: [{
      name: "自查",
      elType: "primary",
//      elIcon: "el-icon-download",
      actionType: 'ids', // query查询 / ids数据处理
      url: '/api/simpleFormDefinition/list',
      opened: true
    }],

    queryUrl: "/api/simpleFormData/findPage", //默认查询后台地址
    queryOnLoad: true, //进入后自动查询

    tableColumns: [{
      prop: 'name',
      label: '姓名',
      width: '100',
    },{
      prop: 'date',
      label: '日期',
      width: '100',
    },{
      prop: 'score',
      label: '分数',
      width: '150',
      component: {
        type: "sftProgress",
        min: 0,
        max: 150,
      }
    },{
      prop: 'address',
      label: '地址',
    }],

    page: {
      pageSizes: [50,100,200],
      disabled: false
    },

  },

  queryFormData: {
    mytext1: null,
    myselect2: null,
    dateStart: null,
    dateEnd: null,
  },

};

const queryFormResult = {
  total: 100,
  rows: [{
    id: 1,
    date: '2016-05-02',
    name: '王小虎',
    score: 60,
    address: '上海市普陀区金沙江路 1518 弄'
  }, {
    id: 2,
    date: '2016-05-04',
    name: '王小虎',
    score: 65,
    address: '上海市普陀区金沙江路 1517 弄'
  }, {
    id: 3,
    date: '2016-05-01',
    name: '王小虎',
    score: 35,
    address: '上海市普陀区金沙江路 1519 弄'
  }, {
    id: 4,
    date: '2016-05-03',
    name: '王小虎',
    score: 80,
    address: '上海市普陀区金沙江路 1516 弄'
  }]
}

export default {
  initQueryForm(queryFormCode) {
    console.log("initQueryForm",queryFormCode);
    // /api/simpleFormData/initQuery?code=$queryFormCode
    const promise = new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 0,
          data: initQueryFormResult
        });
  //        reject(`失败！数字是：${randomNumber}`);
      }, 1000);
    });
    return promise;
  },

  actionQueryFn(url,queryFormCode,queryFormData) {
    console.log("actionQueryFn", url, queryFormCode, queryFormData);
    // post actionDef.url
    const promise = new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 0,
          data: null
        });
  //        reject(`失败！数字是：${randomNumber}`);
      }, 1000);
    });
    return promise;
  },

  actionIdsFn(url,queryFormCode,ids) {
    console.log("actionIdsFn",url,queryFormCode,ids);
    // post actionDef.url
    const promise = new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 0,
          data: null
        });
  //        reject(`失败！数字是：${randomNumber}`);
      }, 1000);
    });
    return promise;
  },

  queryForm(url,queryFormCode,queryFormData){
    console.log("queryForm",url,queryFormCode,queryFormData);
    // post actionDef.url
    const promise = new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 0,
          message: "嘎了",
          data: queryFormResult
        });
  //        reject(`失败！数字是：${randomNumber}`);
      }, 1000);
    });
    return promise;
  }
}